import { http } from '@/utils/request'

// 创建新会话
export function createConversation(params: any) {
  return http.request({
    url: `/ai/createConversation`,
    method: 'GET',
    params
  })
}

// 发送非流式对话
export function sendChat(data: any) {
  return http.request({
    url: `/ai/sendChat`,
    method: 'POST',
    data
  })
}

// 发送流式对话
export function sendStreamChat(data: any) {
  return http.request({
    url: `/ai/sendStreamChat`,
    method: 'POST',
    data
  })
}

// 会话列表
export function conversationList(data: any) {
  return http.request({
    url: `/ai/conversationList`,
    method: 'GET',
    data
  })
}

// 消息列表
export function messageList(data: any) {
  return http.request({
    url: `/ai/messageList`,
    method: 'POST',
    data
  })
}

// 更新会话名称
export function updateConversationTitle(data: any) {
  return http.request({
    url: `/ai/updateConversationTitle`,
    method: 'GET',
    params: data
  })
}

// 删除会话
export function deleteConversation(data: any) {
  return http.request({
    url: `/ai/deleteConversation`,
    method: 'GET',
    params: data
  })
}

// 获取智能体头像
export function getModelProfilePicture() {
  return http.request({
    url: `/ai/getModelProfilePicture`,
    method: 'GET'
  })
}

// 获取智能体信息
export function getAiConfig() {
  return http.request({
    url: `/ai/getAiConfig`,
    method: 'GET'
  })
}

// 获取智能体token
export function getCozeToken() {
  return http.request({
    url: `/ai/getCozeToken`,
    method: 'GET'
  })
}

export function createSpeech(data: any, token: string) {
  return http.request({
    url: `https://api.coze.cn/v1/audio/speech`,
    method: 'POST',
    header: {
      Authorization: `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    data
  })
}

export function getVoicesList(params: any, token: string) {
  return http.request({
    url: `https://api.coze.cn/v1/audio/voices`,
    method: 'GET',
    header: {
      Authorization: `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    params
  })
}